begintownscript;

variables;
short creature_count = 0;
short choice = 0;
short pc_counter = 0;
short lead_char = 0;

body;

beginstate 0; //INIT_STATE
	set_crime_tolerance(2);
	set_name(7, "Helen");
	set_name(9,"Tomas");
	set_name(10, "Harrison");
	set_name(11, "Eli");
	set_level(11,25);
	set_name(12, "Jess");
	set_name(6,"Archer");

	//Fix Scott & Joshua after the blast
	if(get_flag(0,25) == 4) {
		relocate_character(8,58,26);
		set_character_facing(8,4);
		force_instant_terrain_redraw();
		set_name(8, "Private Scott");
		set_name(6, "Joshua");
	}

	//Check to see if Joshua is still there (or if you killed him)
	if((get_flag(1,14) == 1) || (get_flag(6,25) == 1))
		erase_char(6);


	//first entrance
	if(get_flag(1,6) == 0) {
		reset_dialog();
		add_dialog_str(0, "As the sound of rushing water grows louder, you come face to face with the Pearl Bridge, the architectural wonder of Yris province.",0);
		add_dialog_str(1, "You'd expected something more impressive, actually. It's just a bridge. Sure, it's made out of white stone, but it's still just a bridge.",0);
		add_dialog_str(2, "Looking around, you see a few merchants camped by the end of the bridge. This is probably a great place for them to set up shop, since this is supposedly the province's big attraction.",0);
		if(get_flag(0,25) == 4)
			add_dialog_str(3, "The merchants look nervous, probably due to the recent explosion.",0);
		run_dialog(1);
		set_flag(1,6,1);
		}
	
	//Dialogue Pics
	set_char_dialogue_pic(11,1946,0);
	set_char_dialogue_pic(10,1961,0);
	set_char_dialogue_pic(9,1948,0);
	set_char_dialogue_pic(12,1954,0);
	set_char_dialogue_pic(6,1956,0);
	set_char_dialogue_pic(8,1957,0);
	set_char_dialogue_pic(7,1951,0);

break;


beginstate 1; //EXIT_STATE

break;


beginstate 2; //START_STATE
	pc_counter = 0;
	while(char_ok(pc_counter) == 0) {
		pc_counter = pc_counter + 1;
		}
	lead_char = pc_counter;

break;





beginstate 10; //magical braziers - triggered by specobj

//only once
if(get_flag(1,7) == 0) { 
	message_dialog("Looking closely at these braziers, you see that there's no fuel in them. No firewood, no coal, nothing. Thus, you guess it's magic.", "Whoever built this bridge must've been a fairly competent mage, in order to cast such a durable spell.");
	set_flag(1,7,1);
}

break;

beginstate 11; //the campfire

	message_dialog("You lean in to search the fire, and you burn yourselves.","Well, that was stupid.");
	damage_near_loc(6,23,10,1,1);

break;

beginstate 15; //the horse

	if(get_terrain(5,20) != 379)
		end();

	reset_dialog();
	add_dialog_str(0,"This is a horse. You stare at it for a while, and  it stares at you.",0);
	add_dialog_str(1,"Eventually, you realize that this is accomplishing nothing, and you leave it alone.",0);
	run_dialog(1);

break;


beginstate 20; //step onto bridge

if(get_flag(1,8) == 0) {
	message_dialog("Stepping onto the Pearl Bridge for the first time, you're surprised by how smooth and cool the stone feels. Must have something to do with the quickly-flowing water underneath the bridge.","Still, the bridge looks like it was built yesterday, quite an accomplishment for any architect.");
	set_flag(1,8,1);
	}

break;